package jrmob.yonyou.com.commonlib.login.bean;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.TelephonyManager;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 功能说明：
 * 
 * @author zhang
 * @2015-11-9
 */
public class MobileDevice_lib {
	/**
	 * get the device info for the call action
	 * @param context
	 * @return
	 * @throws JSONException
	 */
	public static JSONObject getDeviceInfo(Context context) throws JSONException {
		TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
		String deviceid = tm.getDeviceId();
		WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
		WifiInfo wifiInfo = wifi.getConnectionInfo();
		String wfaddress = wifiInfo.getMacAddress();

		JSONObject deviceJson = new JSONObject();
		if (Build.VERSION.SDK_INT > 8) {
			deviceJson.put("deviceid", Build.SERIAL + deviceid);
		} else {
			deviceJson.put("deviceid", deviceid);
		}
		deviceJson.put("wfaddress", wfaddress);
		deviceJson.put("imei", deviceid);
		deviceJson.put("model", Build.MODEL);
		deviceJson.put("os", "android");
		deviceJson.put("style", "android");
		deviceJson.put("version", Build.VERSION.SDK_INT);
		deviceJson.put("kversion", "3.4.5");
		deviceJson.put("cpu", Build.CPU_ABI);
		deviceJson.put("manufacture", Build.MANUFACTURER);
		deviceJson.put("bootloader", Build.BOOTLOADER);

		return deviceJson;
	}



}
